#include <stdio.h>

int main(){
    int data;
    printf("Enter an integer: ");
    scanf("%d",&data);
    int n[4];
    n[0]=data/1000;
    n[1]=data%1000/100;
    n[2]=data%100/10;
    n[3]=data%10;
    int i;
    for(i=0;i<4;i++){
        n[i]+=5;
        n[i]%=10;
    }
    int out;
    out=n[0]+n[3]*1000+n[1]*100+n[2]*10;
    printf("%d\n",out);
    return 0;
}
